home *** CD-ROM | disk | FTP | other *** search
- ******************************************************************
- * COPYRIGHT (C) 1986 by Donald Krantz and James Stanley
- * - Note: This is a real, live, actual, registered copyright,
- * and should be treated as such. This source code is from
- * the book "68000 Assembly Language", Krantz and Stanley,
- * Addison-Wesley Publishing Company, Reading, MA, 1986.
- *
- * Permission granted by the authors for non-commercial use
- * in programs released to the public domain, as long as this
- * copyright notice remains attached and visible.
- *
- ****************************************************************
- * EXEC - Editor Executive Routine & Globals
- * Contains main editor loop and universal variables.
-
- xref g_3,readfile,refresh,set_edit,open_w,cls,cmd_w
- xref filenm,edit,border_w,set_w
- xdef query,findpat,reppat,repflag,exec,p_buf,p_cnt
- xdef used,get_buf
-
- #edit.h
- #cursor.h
-
- BUFS equ 5 * Max number of open windows
-
- *****************************************************************
- exec:
- bsr init * Initialze local vars
- bsr cls * Initialize virtual screen
- move.l #cmd_w,(a5) * open command I/O window
- bsr border_w *
- bsr get_buf * open buffer
- lpx:
- bsr edit * do editing
- tst.w d0 * look at return code
- beq skx * non-zero means window commands
- bsr g_3 * go do window commands
- bra lpx * resume edit
- * Dump current window
- skx:
- move.l free,a0 * save free list link
- move.l a5,free * put current window in free list
- move.l (a5),a1 * get link to next item in chain
- move.l a1,used * put used list back together
- move.l a0,(a5) * link to free link
- * Relink and Redraw
- tst.l used * get top used window pointer
- beq ed_exit * quit if no more windows
- bsr refresh * redraw the screen
- bra lpx
- ed_exit:
- bsr cls * leave screen pretty
- rts * this is editor exit
- *****************************************************************
- * GET_BUF - finds and opens the next available window
- get_buf:
- tst.l free * check for buffer in free list
- beq no_buf * jump on no buffer
- move.l free,a5 * get next free buffer
- move.l (a5),free * replace free list link
- move.l used,(a5) * link used link
- move.l a5,used * replace used list link
- cmp.l #end_d,defs * see if we overran defaults
- blt sk0_gb * jump if not
- move.l #s_def,defs * reset defaults
- sk0_gb:
- move.l defs,a3 * Get default size window address
- addq.l #8,defs * move pointer for next time
- move.w (a3)+,d0 * Get default upper left X
- move.w (a3)+,d1 * Get default upper left Y
- move.w (a3)+,d2 * Get default lower right X
- move.w (a3)+,d3 * Get default lower right Y
- bsr set_w * Setup window parameters
- bsr set_edit * Setup editor parameters
- bsr readfile * Get filename and file
- move.l #filenm,a0 * Save name of file locally
- lea fname(a5),a1 * A1 is address where name goes
- lp:
- move.b (a0)+,(a1)+ * We just transfer bytes until
- bne lp * we find a null
- bsr open_w * Open the window
- rts
- no_buf:
- * set correct edit error and return
- rts
- *****************************************************************
- * INIT - Initializes local variables
- init:
- move.l #cmd_w,a5 * Open command I/O window
- move.w #0,d0 * set command window limits
- move.w #0,d1
- move.w #79,d2
- move.w #3,d3
- bsr set_w * init command window
- clr.b filenm * zero out current filename
- clr.l used * Zap the in-use buffer pointer
- move.w #BUFS-1,d0 * Buffer count
- move.l #win,a1 * Start the linked list
- move.l a1,free * get the first pointer
- lp0_li:
- move.l a1,a0 * moves pointer up one node
- add.l #DESC,a1 * calcs address of next buffer
- move.l a1,(a0) * loads address of next buffer
- dbra d0,lp0_li * loop for BUFS times
- clr.l (a0) * mark last buffer as end of list
- move.l #defaults,defs * setup default window frame
- rts
- *****************************************************************
- * Default window corners.
- defaults:
- dc.w lim_lx,lim_uy,lim_rx,lim_ly * window 1
- s_def:
- dc.w 1,5,75,15 * Default size of window 2n
- dc.w 2,7,76,17 * Default size of window 3n
- dc.w 3,10,77,20 * Default size of window 4n
- dc.w 4,12,78,22 * Default size of window 5n
- end_d equ *
- *****************************************************************
- bss
- query: ds.b 80 * g.p. query buffer
- findpat:ds.b 80 * find string pattern
- reppat: ds.b 80 * replace string buffer
- repflag:ds.w 1 * "replace" request flag
- defs ds.l 1 * current frame default
- free: ds.l 1 * free buffer linked list ptr
- used: ds.l 1 * in-use buffer link pointer
- win: ds.b DESC*BUFS * editing buffers & pointers
- e_win equ * * end of windows
- p_cnt: ds.w 1 * Char count in paste buffer
- p_buf: ds.b $10000 * 64K paste buffer
-
- end